exports.order_pay = function (req, res) {

    //获取restful参数
    var restfulParams = req.routeInfo.restfulParams;

    //最终结果
    var resultData = {};

    //任务流创建
    async.waterfall([

            //查询订单信息
            function (cb) {

                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.search_order + "/o_id/1",
                        method: 'POST',
                        data: {
                            fields: ["o_no", "o_money", "o_type", "o_aoc_id"].join(",")
                        }
                    },
                    function (err, data) {
                        //判断是否有错误信息
                        if (err) {
                            return cb(err, data);
                        }

                        resultData.organizationOrderData = data.data ;

                        cb();
                    }
                );

            },

            function (cb) {
                // //console.log(resultData.organizationOrderData);
                //创建添加任务
                var tasks = [];

                //循环节点列表
                resultData.organizationOrderData.forEach(function (item, i) {
                    //console.log(item);
                    //创建每一个插入任务
                    tasks.push(function (cb) {
                        //活动
                        if (item.o_type == 0) {
                            // //console.log("00")
                            R.SEND_HTTP(
                                req,
                                {
                                    url: CORE_APIConfig.coreAPI.searchOrganizationActivity + "/oa_id/" + item.o_aoc_id,
                                    method: 'POST',
                                    data: {
                                        // fields:["bpac_id","bpac_new_price"].join(",")
                                        fields: ["oa_title", "oa_title_image"].join(",")
                                    }
                                },
                                function (err, data) {

                                    //console.log(data.data[0]);

                                    item.oa_title = data.data[0].oa_title;
                                    item.oa_img = data.data[0].oa_title_image;
                                    cb();
                                }
                            );
                            //课程
                        } else if (item.o_type == 1) {
                            // //console.log("11")
                            R.SEND_HTTP(
                                req,
                                {
                                    url: CORE_APIConfig.coreAPI.search_organization_course + "/oc_id/" + item.o_aoc_id,
                                    method: 'POST',
                                    data: {
                                        fields: ["oc_title", "oc_title_image"].join(",")
                                    }
                                },
                                function (err, data) {

                                    //console.log(data.data[0]);

                                    item.oc_title = data.data[0].oc_title;
                                    item.oc_title_image = data.data[0].oc_title_image;

                                    cb();
                                }
                            );
                        }
                    });

                });
                async.waterfall(tasks, cb);
            }
        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

};